package com.nCoV.EpidemicSurveillance.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nCoV.EpidemicSurveillance.domain.AreaReach;
import com.nCoV.EpidemicSurveillance.domain.PatientAreaRelation;
import com.nCoV.EpidemicSurveillance.domain.Person;
import com.nCoV.EpidemicSurveillance.scheduled.Tjfx;
import com.nCoV.EpidemicSurveillance.service.DataEntryService;
import com.nCoV.EpidemicSurveillance.service.DataSearchService;

/**
 * @author 罗穆健
 * @date 2020年4月14日
 */
@Controller
@RequestMapping("common")
public class IndexController {
	
	@Autowired
	DataSearchService dataSearchService;
	
	@Autowired
	DataEntryService dataEntryService;
	
	@Autowired
	Tjfx tjfx;
	
	@RequestMapping("getUserMsg")
	@ResponseBody
	public Map<String, Object> getUserMsg(@RequestParam("name")String name,
			@RequestParam("idCard")String idCard){
		return dataSearchService.getUserMsg(name,idCard);
	}
	
	@RequestMapping("getContactor")
	@ResponseBody
	public List<Map<String, Object>> getContactorMsg(@RequestParam("idCard")String idCard){
		return dataSearchService.getContactorMsg(idCard);
	}
	
	@RequestMapping("updateUserMsg")
	@ResponseBody
	public Map<String, Object> updateUserMsg(Person person){
		return dataSearchService.updateUserMsg(person);
	}
	
	@RequestMapping("getTj")
	@ResponseBody
	public List<Map<String, Object>> getTj(){
		return dataSearchService.getTj();
	}
	
	@RequestMapping("getAreaData")
	@ResponseBody
	public List<Map<String, Object>> getAreaData(@RequestParam("address")String address,
			@RequestParam("startTime")String startTime,
			@RequestParam("endTime")String endTime){
		return dataSearchService.getAreaData(address,startTime,endTime);
	}
	
	@RequestMapping("getTrafficData")
	@ResponseBody
	public List<Map<String, Object>> getTrafficData(@RequestParam("trainNumber")String trainNumber,
			@RequestParam("skip")int skipNum,
			@RequestParam("limit")int limitNum){
		return dataSearchService.getTrafficData(trainNumber,skipNum,limitNum);
	}
	
	@RequestMapping("riskAnalysis")
	@ResponseBody
	public List<Map<String, Object>> riskAnalysis(){
		return tjfx.riskAnalysis();
	}
	
	@RequestMapping(value = "addnewarea")
	@ResponseBody
	public Map<String, Object> addNewArea(AreaReach areaReach,PatientAreaRelation patientAreaRelation,
			@RequestParam("patientIdCard")String patientIdCard){
		return dataEntryService.addNewArea(areaReach,patientAreaRelation,patientIdCard);
	}
	
	@RequestMapping(value = "getarearelation")
	@ResponseBody
	public List<Map<String, Object>> getAreaRelationByIdCard(@RequestParam("patientIdCard")String patientIdCard,
			@RequestParam("skip")int skipNum,
			@RequestParam("limit")int limitNum,
			@RequestParam("searchAreaData")String searchAreaData) {
		return dataEntryService.getAreaRelationByIdCard(patientIdCard,skipNum,limitNum,searchAreaData);
	}
}
